package com.byb.server.service.mapper;

import com.byb.server.domain.*;
import com.byb.server.service.dto.EnsureIndex2DTO;

import org.mapstruct.*;

/**
 * Mapper for the entity EnsureIndex2 and its DTO EnsureIndex2DTO.
 */
@Mapper(componentModel = "spring", uses = {ProductMapper.class, EnsureScopeMapper.class, })
public interface EnsureIndex2Mapper extends EntityMapper <EnsureIndex2DTO, EnsureIndex2> {

    @Mapping(source = "product.id", target = "productId")

    @Mapping(source = "ensureScope.id", target = "ensureScopeId")
    @Mapping(source = "ensureScope.index1", target = "ensureScopeIndex1")
    EnsureIndex2DTO toDto(EnsureIndex2 ensureIndex2); 

    @Mapping(source = "productId", target = "product")

    @Mapping(source = "ensureScopeId", target = "ensureScope")
    EnsureIndex2 toEntity(EnsureIndex2DTO ensureIndex2DTO); 
    default EnsureIndex2 fromId(Long id) {
        if (id == null) {
            return null;
        }
        EnsureIndex2 ensureIndex2 = new EnsureIndex2();
        ensureIndex2.setId(id);
        return ensureIndex2;
    }
}
